﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.BIZ;


namespace AnyOffice.general.report.manage
{
    public partial class read_week : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int reportId = (Request.QueryString["report_id"] == null) ? 0 : int.Parse(Request.QueryString["report_id"].ToString());
            DataTable table = new ReportDao().SelectByReportId(base.Conn, reportId);
            if (table.Rows.Count == 0)
            {
                this.pnlMain.Visible = false;
                this.litMessage.Text = base.ShowPromptClose("无周报记录");
            }
            else if (table.Rows[0]["UserId"].ToString() != base.User.Identity.Name)
            {
                this.pnlMain.Visible = false;
                this.litMessage.Text = base.ShowPromptClose("无周报记录");
            }
            else
            {
                this.litTitle.Text = table.Rows[0]["Title"].ToString();
                this.litUserName.Text = "<u title=\"部门：" + table.Rows[0]["DeptName"].ToString() + "\" style=\"CURSOR:hand\">" + table.Rows[0]["UserName"].ToString() + "</u>";
                this.litReportTime.Text = Convert.ToDateTime(table.Rows[0]["ReportTime"].ToString()).ToString("yyyy-MM-dd");
                if (table.Rows[0]["Note1"] != DBNull.Value)
                {
                    this.litNote1.Text = table.Rows[0]["Note1"].ToString().Replace("\n", "<br>");
                }
                if (table.Rows[0]["Note2"] != DBNull.Value)
                {
                    this.litNote2.Text = table.Rows[0]["Note2"].ToString().Replace("\n", "<br>");
                }
                if (table.Rows[0]["Note3"] != DBNull.Value)
                {
                    this.litNote3.Text = table.Rows[0]["Note3"].ToString().Replace("\n", "<br>");
                }
                //if (table.Rows[0]["Note4"] != DBNull.Value)
                //{
                //    this.litNote4.Text = table.Rows[0]["Note4"].ToString().Replace("\n", "<br>");
                //}
                if (table.Rows[0]["AttachmentId"] != DBNull.Value)
                {
                    string attachmentId = table.Rows[0]["AttachmentId"].ToString();
                    if ((this.litAttachment.Text = AttachmentBiz.Display(base.Conn, attachmentId)) != string.Empty)
                    {
                        this.pnlAttachment.Visible = true;
                    }
                    else
                    {
                        this.litAttachment.Text = "无";
                    }
                }
                DataTable table2 = new ReportCommentDao().SelectAll(base.Conn, reportId);
                if (table2.Rows.Count > 0)
                {
                    this.rptComment.DataSource = table2;
                    this.rptComment.DataBind();
                }
            }
        } 

    }
}
